home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Iniviewer
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "IniViewer"
- ClientHeight = 3870
- ClientLeft = 330
- ClientTop = 825
- ClientWidth = 7095
- Height = 4560
- Icon = INIVIEW.FRX:0000
- Left = 270
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 258
- ScaleMode = 3 'Pixel
- ScaleWidth = 473
- Top = 195
- Visible = 0 'False
- Width = 7215
- Begin PictureBox page
- Height = 5580
- Left = 240
- ScaleHeight = 5550
- ScaleWidth = 8985
- TabIndex = 6
- Top = 720
- Width = 9015
- Begin TextBox t
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 5300
- HideSelection = 0 'False
- Index = 1
- Left = 4485
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 0
- Top = 255
- Width = 4530
- End
- Begin TextBox t
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- ForeColor = &H00000000&
- Height = 5300
- HideSelection = 0 'False
- Index = 0
- Left = 0
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 1
- Top = 255
- Width = 4500
- End
- Begin Label ttl
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 255
- Index = 1
- Left = 4485
- TabIndex = 4
- Top = 0
- Width = 4530
- End
- Begin Label ttl
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- FontBold = 0 'False
- FontItalic = 0 'False
- FontName = "MS Sans Serif"
- FontSize = 8.25
- FontStrikethru = 0 'False
- FontUnderline = 0 'False
- Height = 255
- Index = 0
- Left = 0
- TabIndex = 5
- Top = 0
- Width = 4500
- End
- End
- Begin PictureBox tabbox
- BackColor = &H00C0C0C0&
- BorderStyle = 0 'None
- ClipControls = 0 'False
- Height = 495
- Left = 0
- ScaleHeight = 33
- ScaleMode = 3 'Pixel
- ScaleWidth = 529
- TabIndex = 2
- Top = 0
- Width = 7935
- Begin PictureBox invbox
- AutoRedraw = -1 'True
- BackColor = &H00C0C0C0&
- BorderStyle = 0 'None
- ClipControls = 0 'False
- Height = 255
- Left = 1800
- ScaleHeight = 17
- ScaleMode = 3 'Pixel
- ScaleWidth = 81
- TabIndex = 3
- Top = 120
- Visible = 0 'False
- Width = 1215
- End
- End
- Begin CommonDialog cd
- CancelError = -1 'True
- DefaultExt = ".ini"
- Filter = "All Files (*.*)|*.*|Ini Files (*.ini)|*.ini"
- InitDir = "c:\"
- Left = 0
- Top = 360
- End
- Begin Menu zFile
- Caption = "&File"
- Begin Menu zf
- Caption = "&Open..."
- Index = 1
- End
- Begin Menu zf
- Caption = "&Save"
- Index = 2
- End
- Begin Menu zf
- Caption = "Save &As..."
- Index = 3
- End
- Begin Menu zf
- Caption = "Backup Ini Files"
- Index = 4
- End
- Begin Menu zf
- Caption = "-"
- Index = 5
- End
- Begin Menu zf
- Caption = "E&xit"
- Index = 6
- End
- Begin Menu zi
- Caption = "-"
- Index = 0
- End
- Begin Menu zi
- Caption = "autoexec.bat"
- Index = 1
- Shortcut = {F5}
- End
- Begin Menu zi
- Caption = "config.sys"
- Index = 2
- Shortcut = {F6}
- End
- Begin Menu zi
- Caption = "system.ini"
- Index = 3
- Shortcut = {F7}
- End
- Begin Menu zi
- Caption = "win.ini"
- Index = 4
- Shortcut = {F8}
- End
- End
- Begin Menu zedit
- Caption = "&Edit"
- Begin Menu ze
- Caption = "Cu&t"
- Index = 0
- Shortcut = ^X
- End
- Begin Menu ze
- Caption = "&Copy"
- Index = 1
- Shortcut = ^C
- End
- Begin Menu ze
- Caption = "&Paste"
- Index = 2
- Shortcut = ^V
- End
- Begin Menu ze
- Caption = "De&lete"
- Index = 3
- Shortcut = {DEL}
- End
- Begin Menu ze
- Caption = "-"
- Index = 4
- End
- Begin Menu ze
- Caption = "Select &All"
- Index = 5
- End
- Begin Menu ze
- Caption = "-"
- Index = 6
- End
- Begin Menu ze
- Caption = "Time/&Date"
- Index = 7
- End
- End
- Begin Menu zo
- Caption = "&Font"
- Index = 3
- Begin Menu zFontName
- Caption = "FontName"
- Index = 0
- End
- End
- Option Explicit
- Dim i%, r%, s$
- Dim dirty%(0 To 1)
- Dim inifile$(0 To 1)
- Dim tlines%(0 To 1)
- Dim showlist%
- Dim tb As TabData
- Dim captions$()
- Dim ftb As TabData
- Sub BackupIni ()
- Dim f$
- screen.MousePointer = 11
- s$ = App.Path & "\backup"
- If Dir(s$, 16) = "" Then MkDir s$
- CopyFile "c:\autoexec.bat", "autoexec.xxx"
- CopyFile "c:\config.sys", "config.xxx"
- CopyFile "c:\windows\system.ini", "system.xxx"
- CopyFile "c:\windows\win.ini", "win.xxx"
- screen.MousePointer = 0
- End Sub
- Sub CopyFile (Filename$, temp$)
- Dim fnum%, lng&, f$, t$
- On Error GoTo cerr
- fnum = FreeFile ' get next handle number
- Open Filename$ For Binary As #fnum%
- lng& = LOF(fnum)
- s$ = String$(lng, " ")
- Get #fnum%, , s$
- Close #fnum%
- fnum = FreeFile ' get next handle number
- f$ = App.Path & "\backup\" & temp$
- t$ = Dir(f$)
- If t$ <> "" Then
- Kill f$
- End If
- Open f$ For Binary As #fnum%
- Put #fnum, , s$
- Close #fnum
- Exit Sub
- cerr:
- Close #fnum
- MsgBox "Error copying " & Filename$
- Exit Sub
- End Sub
- Sub Form_Load ()
- crlf$ = Chr$(13) + Chr$(10)
- zFontName(0).Caption = screen.Fonts(0)
- For i = 1 To screen.FontCount - 1
- Load zFontName(i)
- zFontName(0).Caption = screen.Fonts(i)
- Initialize
- iniviewer.Show
- zi_click 1
- End Sub
- Sub Form_QueryUnload (Cancel As Integer, UnloadMode As Integer)
- Dim msg, Filename
- Dim response As Integer
- For i = 0 To 1
- If dirty(i) Then
- Filename = inifile(i)
- msg = "The text in [" & Filename & "] has changed."
- msg = msg & crlf$
- msg = msg & "Do you want to save the changes?"
- r = MsgBox(msg, 51, "IniViewer")
- Select Case r
- ' Yes
- Case 6
- Filename = GetFName(2)
- 'If the user did notspecify a file name,
- 'cancel the unload; otherwise, save it.
- If Filename = "" Then
- Cancel = True
- Else
- SaveFileAs (Filename)
- End If
- ' User selects No
- ' Ok to unload
- Case 7
- GoTo skip
- ' User selects Cancel
- ' Cancel the unload
- Case 2
- Cancel = True
- Exit For
- End Select
- skip:
- End If
- End Sub
- Function GetFName (n%)
- On Error Resume Next
- cd.Action = n%
- If Err <> 32755 Then 'User cancelled dialog
- GetFName = cd.Filename
- Else
- GetFName = ""
- End If
- End Function
- Sub Initialize ()
- '===create an array of controls=======
- ReDim captions(0 To 3)
- captions(0) = "autoexec.bat"
- captions(1) = "config.sys"
- captions(2) = "system.ini"
- captions(3) = "win.ini"
- '===fill in the fields of the struct=====================
- tb.num = 3 'number of tabs
- tb.active = 0 'initial focus
- tb.cols = 4 'number of tabs in each row
- tb.insetx = 4
- tb.insety = 4
- DefineControl Me, tabbox, invbox, page, tb
- End Sub
- Sub OpenIniFile (f$, ndx%)
- Dim fnum%, lng&
- 'If lbox.Visible Then zb_click 13
- On Error GoTo ierr
- fnum = FreeFile ' get next handle number
- Open f$ For Binary As #fnum%
- lng& = LOF(fnum)
- s$ = String$(lng, " ")
- Get #fnum%, , s$
- Close #fnum%
- t(ndx%) = s$
- tlines(ndx) = SendMessage(t(ndx).hWnd, EM_GETLINECOUNT, 0, 0&)
- ttl(ndx%) = Format(tlines(ndx), "@@@@") & " : " & LCase(f$)
- dirty(ndx%) = 0
- Exit Sub
- ierr:
- MsgBox "Can't open " & f$
- Exit Sub
- End Sub
- Sub SaveFileAs (Filename)
- On Error Resume Next
- s = Dir(Filename)
- If s <> "" Then
- If MsgBox("[" & UCase(Filename) & "]" & "already exists." & crlf & crlf & " Overwrite?", 36, "INIVIEWER") <> 6 Then Exit Sub
- End If
- Open Filename For Output As #1
- s = t(active)
- screen.MousePointer = 11
- Print #1, s
- Close #1
- screen.MousePointer = 0
- If Err Then MsgBox Error, 48, App.Title
- End Sub
- Sub t_Change (Index As Integer)
- dirty(Index) = True
- End Sub
- Sub t_GotFocus (Index As Integer)
- Dim other%
- active = Index
- If active = 0 Then other = 1
- t(active).ForeColor = QBColor(0)'black
- t(other).ForeColor = QBColor(8)
- End Sub
- Sub tabbox_MouseUp (Button As Integer, Shift As Integer, X As Single, Y As Single)
- TabClick Button, X, Y, tabbox, captions(), tb
- zi_click tb.active + 1
- t(0).SetFocus
- End Sub
- Sub tabbox_Paint ()
- DrawText tabbox, captions(), tb
- End Sub
- Sub ttl_Click (Index As Integer)
- 'caption labels for the files
- End Sub
- Sub ze_click (Index As Integer) 'edit
- Select Case Index
- Case 0
- ClipBoard.SetText t(active).SelText
- t(active).SelText = ""
- Case 1
- ClipBoard.SetText t(active).SelText
- Case 2
- t(active).SelText = ClipBoard.GetText()
- Case 3
- If t(active).SelStart <> Len(t(active).Text) Then
- ' If nothing is selected, extend selection by one.
- If t(active).SelLength = 0 Then
- t(active).SelLength = 1
- ' If cursor is on a blank line, extend selection by two.
- If Asc(t(active).SelText) = 13 Then
- t(active).SelLength = 2
- End If
- End If
- ' Delete selected text.
- t(active).SelText = ""
- End If
- Case 5
- t(active).SelStart = 0
- t(active).SelLength = Len(t(active).Text)
- Case 7
- t(active).SelStart = 0: t(active).SelLength = 0
- If Right$(t(active).Tag, 3) = "ini" Then
- s = "; "
- s = "REM "
- End If
- t(active).SelText = s & Now & crlf$
- End Select
- End Sub
- Sub zf_click (Index As Integer)
- Select Case Index
- Case 1'open
- s = GetFName(1)
- If s$ <> "" Then
- t(active).Tag = s$
- OpenIniFile s$, active
- End If
- Case 2'save
- s = t(active).Tag
- If s = "" Then Beep: Exit Sub
- If Not dirty(active) Then MsgBox "[" & UCase(s$) & "]" & crlf$ & crlf$ & "is up to date.", , "INIVIEWER": Exit Sub
- If s$ <> "" Then SaveFileAs (s$)
- Case 3'saveas
- s = t(active).Tag
- If s = "" Then Beep: Exit Sub
- cd.Filename = s
- s = GetFName(2)
- If s <> "" Then
- t(active).Tag = s
- SaveFileAs (s)
- End If
- Case 4
- BackupIni
- Case 6'exit
- Unload Me
- End Select
- End Sub
- Sub zFontName_Click (Index As Integer)
- For i = 0 To 1
- t(i).FontName = zFontName(Index).Caption
- End Sub
- Sub zi_click (Index As Integer)
- Select Case Index
- Case 1
- t(0).Tag = "c:\autoexec.bat"
- t(1).Tag = App.Path & "\backup\autoexec.xxx"
- Case 2
- t(0).Tag = "c:\config.sys"
- t(1).Tag = App.Path & "\backup\config.xxx"
- Case 3
- t(0).Tag = "c:\windows\system.ini"
- t(1).Tag = App.Path & "\backup\system.xxx"
- Case 4
- t(0).Tag = "c:\windows\win.ini"
- t(1).Tag = App.Path & "\backup\win.xxx"
- End Select
- OpenIniFile CStr(t(0).Tag), 0
- OpenIniFile CStr(t(1).Tag), 1
- t(0).SetFocus
- End Sub
- Sub zo_click (Index As Integer) 'font
- End Sub
-